<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>

<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="station" class="layui-hide" lay-filter="t"></table>
        </div>

    </div>
</div>
</body>
<script type="text/html" id="tb">
    <div class="layui-container">
        <span class="">欢迎界面列表</span>
    </div>
</script>
<script type="text/html" id="sh">
    <input type="button" id="dsh" value="未审核" class="layui-btn layui-btn-sm" lay-event="shenhe"/>
</script>
</body>
<script>
    layui.use(['laydate', 'form', 'table'], function () {
        var $ = layui.$;

        var form = layui.form;
        var table = layui.table;

        table.render({
            elem: "#station",
            url: "/admin/theme/welcomepageshenhe",
            id: "t",
            toolbar: '#tb',
            cols: [
                [{
                    title: "站点名称",
                    field: "station_name",
                    width: "20%",
                    fixed: "left",
                    align: "center"
                }, {
                    title: "欢迎语标题",
                    field: "welcome_page_text",
                    width: "20%",
                    align: "center"
                }, {
                    title: "欢迎语内容",
                    field: "welcome_page_text",
                    width: "20%",
                    align: "center"
                }, {
                    title: "背景图片",
                    field: "welcome_page_file",
                    templet: function(d) {
                        return "<img width='50px' height='50px' src='"+"http://127.0.0.1:8080/upload/" + d.welcome_page_file + "'></img>";
                    },
                    width: "20%",
                    align: "center"
                }, {
                    title: "操作",
                    width: "20%",
                    align: "center",
                    toolbar: "#sh",
                    fixed: "right"
                }, {
                    title: "id",
                    field: "theme_id",
                    hide: true
                }

                ]
            ],
            page: true,
        });
        //    右侧按钮的的监听事件
        table.on("tool(t)", function (obj) {
            var getdata = obj.data; //获得当前行数据
            var layEvent = obj.event;
            var tr=obj.tr;
            switch (layEvent) {
                case"shenhe":
                    var close = layer.confirm("确定审核吗?", {
                        title: "提示",
                        btn: ["确定", "取消"],
                        btn1: function () {
                            $.ajax({
                                type: "post",
                                url: "/admin/theme" +
                                    "/updateshenhe",
                                async: true,
                                data: {
                                    themeId: getdata.theme_id,
                                },
                                success: function (res) {
                                    if (res.code == 200) {
                                        $(tr).remove();
                                        layer.close(close);
                                        layer.msg('审核成功', {
                                            icon: 1
                                        });
                                        return;
                                    }
                                    layer.msg('修改失败', {
                                        icon: 2
                                    });

                                }
                            })
                        }

                    })

                    break;
            }
        });

    })
</script>

</html>